const Sequelize = require('sequelize');
const {db:{database, username, password, host, dialect}} = require('../config');

const sequelize = new Sequelize(database, username, password, {
    host,
    dialect,
    operatorsAliases: false,
    pool: {
        max: 5,
        min: 0,
        acquire: 30000,
        idle: 10000
    }
});

sequelize.authenticate().then(() => {
    console.log('Connection has been established successfully.');
}).catch(err => {
    console.log('Unable to connect to the database:', err);
});

module.exports = sequelize;